<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<title>订单执行管理</title>

	<!-- bootstrap -->
	<link href="__CSS__/bootstrap/bootstrap.css" rel="stylesheet" />

	<!-- libraries -->
	<!-- <link href="css/libs/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /> -->
	<link href="__CSS__/libs/font-awesome.css" type="text/css" rel="stylesheet" />

	<!-- global styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/layout.css">
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/elements.css">

	<!-- this page specific styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/libs/bootstrap-wizard.css">
	<link rel="stylesheet" href="__CSS__/libs/select2.css" type="text/css" />

	<link rel="stylesheet" href="__CSS__/new.css"/>
	<link rel="stylesheet" href="__CSS__/table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table-fixed-columns.css"/>
	<link rel="stylesheet" href="__CSS__/other.css"/>

	<!-- Favicon -->
	<!--<link type="image/x-icon" href="favicon.png" rel="shortcut icon"/>-->

	<!-- google font libraries -->
	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>

	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'UA-49262924-1', 'phoonio.com');
	  ga('send', 'pageview');

	</script>
	<style>
		.main-box{
			min-height: 820px;
		}
		@media (max-width:1320px){
			.main-box{
				min-height: 700px;
			}
		}

		.fixed-table-body-columns{
			height: 486px!important;
			top: 47px!important;
		}
		.calCancel{
			float: right;
		}
		.wizard-modal.modal{
			width:680px!important;
			/*height: 360px!important;*/
			margin-left: -336px!important;
		}
		#msg{
			background: rgba(255,255,255,0.6);
			border:1px solid #faf2cc;
			text-align:center;
			max-width: 220px;
			min-width: 150px;
			height: 30px;
			margin-left: 50%;
			border-radius: 3px;
		}
		/*固定前两列宽度设置*/
		.addWidth{
			width: 86px;
		}
		.temp{
			width: 50px;
		}
	</style>
</head>
<body>
	<!--head-->
	{include file="pub/head"/}

	<div class="container" role="main">
		<div class="row">

				<!--left-->
				{include file="pub/left"/}

			<div class="col-md-10" id="content-wrapper">
				<!--<h2 class="pull-left">Last orders</h2>-->
				<div class="row">
					<div class="col-lg-12">
						<!--<div class="row">
							<div class="col-lg-12">-->
								<div class="main-box">
									<!--提示框-->
									<div id="msg">
										<img src="__IMG__/success.png" id="img" alt="" style="float: left;height: 29px;width: 36px;">
										<span id="sp" style="font-size: 14px;line-height: 30px;">提示信息</span>
									</div>
									<div class="clear-fix">
										{if condition="in_array('Execorder/save',$ownways)"}
										<button id="open-wizard" class="btn btn-primary">
											<i class="fa fa-plus-circle fa-lg"></i> 添加订单执行
										</button>
										{/if}
									</div>
									<!--搜索页-->
									<div class="col-sm-12 col-md-12 col-lg-12 col-xs-12" style="margin-top: 16px;">
										{include file="eord/search"/}
									</div>
									<div class="table-responsive clearfix">
										<table id="fixedTable" class="table table-striped jambo_table table-hover" data-toggle="table">
											<thead>
												<tr>
													<th><span>国家</span></th>
													<th><span>客户</span></th>

													{if condition="$status neq 3"}
													<th><span>订单评审号</span></th>
													<th><span>业务部</span></th>
													<th><span>基表型号</span></th>
													{/if}

													<th><span>订单数量</span></th>
													<th><span>电子模块类型</span></th>
													<th><span>生产状态</span></th>
													<th><span>发货状态</span></th>

													{if condition="$status neq 3"}
													<th><span>模块订单号</span></th>
													<th><span>模块数量</span></th>
													<th><span>模块订单周期(天)</span></th>
													<th><span>基表组装周期(天)</span></th>
													{/if}

													{if condition="$status eq 3"}
													<th><span>模块交付日期</span></th>
													{/if}

													<th><span>基表订单号</span></th>
													<th><span>表号</span></th>
													<th><span>制造商</span></th>

													{if condition="$status neq 3"}
													<th><span>生产负责人</span></th>
													{/if}

													<th><span>客户化工具</span></th>
													<th><span>生产数据校验</span></th>
													<th><span>备注说明</span></th>

													{if condition="$status neq 3"}
													<th><span>订单金额（单位）</span></th>
													{/if}

													<th class="text-center"><span>操作</span></th>
												</tr>
											</thead>
											<tbody>
												{volist name="orderexecs" id="v"}
												<tr>
													<td class="addWidth">{$v.state}</td>
													<td>{$v.client}</td>

													{if condition="$status neq 3"}
													<td>{$v.oid}</td>
													<td>{$v.sale}</td>
													<td>{$v.meter_type}</td>
													{/if}

													<td>{$v.order_qty}</td>
													<td>{$v.model_type}</td>
													<td>{$v.delivery_status}</td>
													{if condition="$v['is_status'] eq 1"}
													<td>已发货</td>
													{else/}
													<td>未发货</td>
													{/if}

													{if condition="$status neq 3"}
													<td>{$v.model_num}</td>
													<td>{$v.model_qty}</td>
													<td>{$v.order_cycle}</td>
													<td>{$v.assem_cycle}</td>
													{/if}
													{if condition="$status eq 3"}
													<td>{$v.model_end}</td>
													{/if}

													<td>{$v.order_num}</td>
													<td>{$v.meter_start}~{$v.meter_end}</td>
													<td>{$v.manufacturer}</td>

													{if condition="$status neq 3"}
													<td>{$v.product_principle}</td>
													{/if}

													<td>{$v.custom}</td>
													<td>{$v.data}</td>
													<td>{$v.comments}</td>

													{if condition="$status neq 3"}
													<td>{$v.sum_amounts} {$v.sum_units}</td>
													{/if}

													<td>
														{if condition="in_array('Execorder/view',$ownways)"}
														<a href="{:url('Execorder/view',['oid_exec'=>$v['oid_exec']])}" class="table-link" title="查看详情">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-search-plus fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
														{if condition="in_array('Execorder/esave',$ownways)"}
															{if condition="$status neq 3"}
															<a class="table-link" href="#" onclick=edit("{$v['oid_exec']}") title="修改信息">
																<span class="fa-stack">
																	<i class="fa fa-square fa-stack-2x"></i>
																	<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
																</span>
															</a>
															{else/}
															<a class="table-link" href="#" onclick=editFor("{$v['oid_exec']}") title="修改信息">
																<span class="fa-stack">
																	<i class="fa fa-square fa-stack-2x"></i>
																	<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
																</span>
															</a>
															{/if}
														{/if}
														{if condition="in_array('Execorder/esta',$ownways)"}
														<a class="table-link" href="#" onclick=estatus("{$v['oid_exec']}") title="修改发货状态">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil-square fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
														{if condition="in_array('Execorder/del',$ownways)"}
														<a class="table-link danger class-del" href="#" onclick=del("{$v['oid_exec']}") title="删除">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
													</td>
												</tr>
												{/volist}

											</tbody>
										</table>
										<!--分页-->
										<div style="text-align: center;">
											{$page}
										</div>
									</div>

									<!--添加弹出框-->
									{include file="eord/add"/}
									<!--修改弹出框-->
									<!--修改信息-->
									{include file="eord/edit"/}
									{include file="eord/estatus"/}
									{include file="eord/editfor3"/}
									<!--删除弹出框-->
									{include file="eord/del"/}

								</div>
							</div>
						</div>
						
					<!--</div>
				</div>-->
			</div>
		</div>
	</div>
	<!--foot-->
	{include file="pub/foot"/}

	<!-- global scripts -->
	<script src="__JS__/jquery.js"></script>

	<script src="__JS__/bootstrap.min.js"></script>

	<!-- this page specific scripts -->
	<script src="__JS__/bootstrap-wizard.js"></script>
	<script src="__JS__/select2.min.js"></script>

	<!-- theme scripts -->
	<script src="__JS__/scripts.js"></script>
	<script src="__JS__/bootstrap-table.js"></script>
	<script src="__JS__/bootstrap-table-fixed-columns.js"></script>
	<script>
        $('#fixedTable').bootstrapTable('destroy').bootstrapTable({
            fixedColumns: true,//固定列
            fixedNumber:2 //固定前两列
        })


		$('#sel2').select2();

		$.fn.wizard.logging = false;

		var wizard = $("#wizard-demo").wizard({
			showCancel: true
		});
        var foredit = $("#wizard-edit").wizard({
            showCancel: true
        });
        var foreditpa = $("#wizard-pa").wizard({
            showCancel: true
        });
        var foreditstatus = $("#wizard-est").wizard({
            showCancel: true
        });
		var foreditfor = $("#wizard-for").wizard({
            showCancel: true
        });

		wizard.el.find(".wizard-ns-select").change(function() {
			wizard.el.find(".wizard-ns-detail").show();
		});

		wizard.el.find(".create-server-service-list").change(function() {
			var noOption = $(this).find("option:selected").length == 0;
			wizard.getCard(this).toggleAlert(null, noOption);
		});

		wizard.cards["name"].on("validated", function(card) {
			var hostname = card.el.find("#new-server-fqdn").val();
		});

		wizard.on("submit", function(wizard) {
			/*var submit = {
				"hostname": $("#new-server-fqdn").val()
			};*/

			setTimeout(function() {
				wizard.trigger("success");
				wizard.hideButtons();
				wizard._submitting = false;
				wizard.showSubmitCard("success");
				wizard.updateProgressBar(0);
			}, 2000);
			add();
			wizard.reset().close();
			//刷新页面
			window.location.reload();
		});
		$(".wizard-group-list").click(function() {
			alert("Disabled for demo.");
		});

		$("#open-wizard").click(function() {
			wizard.show();
			/*$('.wizard-cancel').text('取消');
			$('.wizard-back').text('上一步')
			$('.wizard-next').text('下一步');
			$('.btn-success').text('确定')*/
		});

		//wizard.show();

        $("#msg").addClass('forhid')

        function add() {
            /*订单评审信息*/
            var oid = $("select[name='oid_add']").val();

			/*模块信息*/
            var model_qty = $("input[name='model_qty_add']").val();
            var model_id = $("select[name='model_id_add']").val();
            var model_num = $("input[name='model_num_add']").val();
            var model_start = $("input[name='model_start_add']").val();
            var model_end = $("input[name='model_end_add']").val();

			/*基表信息*/
            var order_num = $("input[name='order_num_add']").val();
            var meter_start = $("input[name='meter_start_add']").val();
            var meter_end = $("input[name='meter_end_add']").val();
            var assem_start = $("input[name='assem_start_add']").val();
            var assem_end = $("input[name='assem_end_add']").val();

			/*生产信息*/
            var mf_id = $("select[name='mf_id_add']").val();
            var pid = $("select[name='pid_add']").val();
            var custom_tool = $("select[name='custom_tool_add']").val();
            var data_verify = $("select[name='data_verify_add']").val();
            var is_status = $("select[name='is_status_add']").val();

			/*其他相关信息*/
            var sale_id = $("select[name='sale_id_add']").val();
            var sum_amounts = $("input[name='sum_amounts_add']").val();
            var sum_units = $("select[name='sum_units_add']").val();
            var comments = $("input[name='comments_add']").val();

            var data = {'oid':oid,'model_qty':model_qty,'model_id':model_id,'model_num':model_num,'model_start':model_start,'model_end':model_end,
				'order_num':order_num,'meter_start':meter_start,'meter_end':meter_end,'assem_start':assem_start,'assem_end':assem_end,
				'mf_id':mf_id,'pid':pid,'custom_tool':custom_tool,'data_verify':data_verify,'is_status':is_status,
				'sale_id':sale_id,'sum_amounts':sum_amounts,'sum_units':sum_units, 'comments':comments};
            //console.log(data)
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "{:url('Execorder/save')}",//url
                data: data,
                success: function (result) {
                    var code = result.code
                    var msg = result.msg
                    changeText(msg, code)
                    //console.log('123'+msg)

                },
                error:function (result) {
                    var code = 0
                    var msg = '服务器错误';
                    changeText(msg, code)

                }
            });
        }
        function changeText(msg, code) {
            $('#sp').text(msg)
            if(code != 1){
                $('#img').attr('src', '__IMG__/fail.png')
            }
            $("#msg").removeClass('forhid')
            setTimeout("showOrHid()", 2000)
        }
        function showOrHid() {
            //console.log('123')
            $("#msg").addClass('forhid')
        }

        function del(oid_exec) {
            $.post("{:url('Execorder/one')}",{oid_exec:oid_exec},function(data){
                //console.log(data);
                if(data) {
                    $("input[name='oid_exec']").val(data[0].oid_exec)
                }
            },'json');

        }

        $(function () {
            $(".alert-close").click(function () {
                $(".delete").css("display","none")
            })
            $(".alert-cancel").click(function () {
                $(".delete").css("display","none")
            })
            $(".class-del").click(function () {
                $(".delete").css("display","block")
            })

        })
	</script>
</body>
</html>